package observer.b;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class SwingObserverExample {

	JFrame jframe;
	
	public static void main(String[] args) {
		SwingObserverExample swingObserverExample = new SwingObserverExample();
		swingObserverExample.go();
	}
	
	public void go() {
		jframe = new JFrame();
		JButton jbutton = new JButton();
		
		jbutton.addActionListener(new AngelListener());
		jbutton.addActionListener(new DevilListener());
		
		jframe.getContentPane().add(BorderLayout.CENTER, jbutton);
		jframe.setVisible(true);
	}
	
	class AngelListener implements ActionListener {
		public void actionPerformed(ActionEvent event) {
			System.out.println("Don't do it.");
		}
	}
	
	class DevilListener implements ActionListener {
		public void actionPerformed(ActionEvent event) {
			System.out.println("Do it.");
		}
	}
}
